<style lang="less">
  @import '../styles/common.less';
  @import '../tables/components/table.less';
</style>

<template>
  <div>
    <Row :gutter="10">
      <Card>
        <div class="table-head">
          <div class="left">
            <Select v-model="typeSelectid" :transfer="true" @on-change="onChangeTypeSelect">
              <Option v-for="item in typeSelect" :value="item.id" :key="item.id">{{ item.title }}</Option>
            </Select>
          </div>
          <div class="left">
            <DatePicker
                type="daterange"
                placement="bottom-start"
                placeholder="时间段"
                v-model="searchDatePicker"
                style="width: 100%;"></DatePicker>
          </div>
          <div class="left-btn">
            <Button type="primary" @click="searchFun()">搜索</Button>
          </div>
          <Button type="primary" class="Button" @click="ExportData()">导出数据</Button>
          <Button type="primary" class="Button" @click="remove()">删除</Button>
          <Button type="primary" class="Button" @click="add()">添加</Button>
        </div>
        <Row class="margin-top-10">
          <Table stripe border :columns="columns" :data="data" @on-row-click="onRowData" @on-sort-change="onSortChange"
                 @on-selection-change="selectionChange"></Table>
        </Row>
        <div style="margin: 10px;overflow: hidden;height: 36px;">
          <div style="float: right;">
            <Page :total="total" :current="page" @on-change="changePage" show-elevator></Page>
          </div>
        </div>
      </Card>
      <!--详情-->
      <Drawer :closable="false" :width="DrawerWidth" v-model="showCurrentTableData" class="Drawer-body">
        <div class="Drawer_pStyle">
          <span></span>
          <span class="del" @click="asyncOK"><Icon type="md-close"/></span>
        </div>
        <div class="body">
          <Form label-position="top">
            <FormItem label="创建人">
              <div class="dataDetail-div" v-text="dataDetail.uname"></div>
            </FormItem>
            <FormItem label="标题">
              <div class="dataDetail-div" v-text="dataDetail.title"></div>
            </FormItem>
            <FormItem label="类别" v-if="dataDetail.type">
              <div class="dataDetail-div" v-text="dataDetail.type.title"></div>
            </FormItem>
            <FormItem label="标签" v-if="dataDetail.tags">
              <div class="dataDetail-div" v-text="dataDetail.tags"></div>
            </FormItem>
            <FormItem label="时间" v-if="dataDetail.start_time">
              <div class="dataDetail-div" v-text="dataDetail.start_time"></div>
            </FormItem>
            <FormItem label="可见范围">
              <div class="dataDetail-div" v-text="show_users"></div>
            </FormItem>
            <FormItem label="内容" v-if="dataDetail.content">
              <div class="dataDetail-div ck-editor-content" v-html="dataDetail.content"></div>
            </FormItem>
            <FormItem label="附件" v-if="dataDetail.accessory && dataDetail.accessory.length > 0">
              <div class="dataDetail-div">
                <div v-for="el in dataDetail.accessory">
                  <a :href="el.path" target="_blank"
                     v-if="el.suffiix == '.pdf'"
                  >{{el.name}}</a>
                  <a :href="officeappsUrl + el.path" target="_blank"
                     v-else-if="el.suffiix == '.doc' || el.suffiix == '.docx' || el.suffiix == '.xls' || el.suffiix == '.xlsx' || el.suffiix == '.pptx' || el.suffiix == '.ppt'"
                  >{{el.name}}</a>
                  <a @click="DownloadFile(el.path, el.name)"
                     v-else
                  >{{el.name}}</a>
                </div>
              </div>
            </FormItem>
            <FormItem label="人员阅读状态">
              <div class="dataDetail-div padding-0">
                <Table stripe border :columns="readList_columns" :data="readList"></Table>
                <div class="readList_page_div text-align-center" v-if="readList_total > 0">
                  <Page :total="readList_total" :current="readList_page" size="small" @on-change="readList_changePage"
                        show-elevator></Page>
                </div>
              </div>
            </FormItem>
            <FormItem label="">
              <div class="action-button-div">
                <div class="action"
                     v-if="dataDetail.subject && dataDetail.subject.praise">
                  <div class="support" @click="supportFun(dataDetail.id, dataDetail.subject.praise.is_support)">
                    <Icon type="ios-thumbs-up"
                          v-if="dataDetail.subject.praise.is_support.toString() == 'true' && dataDetail.subject.praise.is_support.toString() != ''"/>
                    <Icon type="ios-thumbs-up-outline"
                          v-if="dataDetail.subject.praise.is_support.toString() == 'false' || dataDetail.subject.praise.is_support.toString() == ''"/>
                    {{dataDetail.subject.praise.support}}
                  </div>
                  <div class="against" @click="againstFun(dataDetail.id, dataDetail.subject.praise.is_support)">
                    <Icon type="ios-thumbs-down"
                          v-if="dataDetail.subject.praise.is_support.toString() == 'false' && dataDetail.subject.praise.is_support.toString() != ''"/>
                    <Icon type="ios-thumbs-down-outline"
                          v-if="dataDetail.subject.praise.is_support.toString() == 'true' || dataDetail.subject.praise.is_support.toString() == ''"/>
                    {{dataDetail.subject.praise.against}}
                  </div>
                  <div class="comments" @click="commentsFun(dataDetail.id)">
                    <Icon type="ios-text"/>
                    <span
                        v-if="dataDetail.show_comments_list != true">评论（{{dataDetail.subject.reply.reply_number > 0 ? dataDetail.subject.reply.reply_number : 0}}）</span>
                    <span v-if="dataDetail.show_comments_list == true">收起评论</span>
                  </div>
                  <div class="collection"
                       @click="collectionFun(dataDetail.id, dataDetail.subject.collection.is_collection)">
                    <Icon type="ios-star" v-if="dataDetail.subject.collection.is_collection.toString() == 'true'"/>
                    <Icon type="ios-star-outline"
                          v-if="dataDetail.subject.collection.is_collection.toString() == 'false'"/>
                    收藏
                  </div>
                  <div class="collection"
                       @click="answerFun(dataDetail.id)">
                    <Icon type="md-create" v-if="myAnswer == false"/>
                    <span v-if="myAnswer == false">写回答</span>
                    <Icon type="md-list" v-if="myAnswer == true"/>
                    <span v-if="myAnswer == true && show_myanswer_content != true">查看我的回答</span>
                    <span v-if="myAnswer == true && show_myanswer_content == true">收起我的回答</span>
                  </div>
                </div>
              </div>
              <div class="comments-list comments-list-div" v-if="dataDetail.show_comments_list == true">
                <comments-list
                    reply_type="knowledge"
                    :reply_type_id="dataDetail.id"
                ></comments-list>
              </div>
              <div class="answer-list-div" v-if="show_answer_content == true">
                <div id="answer_content" class="ck-editor-content"
                     style="width: 100%;min-height: 100px;margin-bottom: 20px;"></div>
                <div class="input">
                  <Button type="primary" class="Button" @click="addAnswerFun()">提交回答
                  </Button>
                  <Button type="text" class="Button" @click="clearAnswerFun()">取消</Button>
                </div>
              </div>
              <!--我的回答-->
              <div class="answer-list-div border-top"
                   v-if="show_answer_content == false && myAnswer == true && show_myanswer_content == true">
                <div class="answer-list-div-user">
                  <div class="user">
                    <table class="table-user" cellpadding="0" cellspacing="0">
                      <tr>
                        <td class="td1">
                          <img class="cursor" :src="myAnswerObj.user.thumb" alt="头像"
                               @click="searchUserInfo(myAnswerObj.user.id)"
                               v-if="myAnswerObj.user && myAnswerObj.user.thumb">
                          <img class="cursor" src="/vendors/images/person.png" alt="头像"
                               @click="searchUserInfo(myAnswerObj.user.id)"
                               v-if="!(myAnswerObj.user && myAnswerObj.user.thumb)">
                        </td>
                        <td class="td2">
                          <div class="name" v-text="myAnswerObj.user.name"></div>
                        </td>
                        <td class="td3">
                          <div class="time" v-text="myAnswerObj.create_time"></div>
                        </td>
                        <td class="td4">
                          <div class="name">
                            <span @click="updateAnswerFun()">修改</span>
                          </div>
                        </td>
                      </tr>
                    </table>
                  </div>
                </div>
                <div class="content" v-html="myAnswerObj.content"></div>
                <div class="action-button-div">
                  <div class="action"
                       v-if="myAnswerObj.subject && myAnswerObj.subject.praise">
                    <div class="support"
                         @click="answer_supportFun(myAnswerObj.id, myAnswerObj.subject.praise.is_support)">
                      <Icon type="ios-thumbs-up"
                            v-if="myAnswerObj.subject.praise.is_support.toString() == 'true' && myAnswerObj.subject.praise.is_support.toString() != ''"/>
                      <Icon type="ios-thumbs-up-outline"
                            v-if="myAnswerObj.subject.praise.is_support.toString() == 'false' || myAnswerObj.subject.praise.is_support.toString() == ''"/>
                      {{myAnswerObj.subject.praise.support}}
                    </div>
                    <div class="against"
                         @click="answer_againstFun(myAnswerObj.id, myAnswerObj.subject.praise.is_support)">
                      <Icon type="ios-thumbs-down"
                            v-if="myAnswerObj.subject.praise.is_support.toString() == 'false' && myAnswerObj.subject.praise.is_support.toString() != ''"/>
                      <Icon type="ios-thumbs-down-outline"
                            v-if="myAnswerObj.subject.praise.is_support.toString() == 'true' || myAnswerObj.subject.praise.is_support.toString() == ''"/>
                      {{myAnswerObj.subject.praise.against}}
                    </div>
                    <div class="comments" @click="answer_commentsFun(myAnswerObj.id)">
                      <Icon type="ios-text"/>
                      <span
                          v-if="myAnswerObj.show_comments_list != true">评论（{{myAnswerObj.subject.reply.reply_number > 0 ? myAnswerObj.subject.reply.reply_number : 0}}）</span>
                      <span v-if="myAnswerObj.show_comments_list == true">收起评论</span>
                    </div>
                    <div class="collection"
                         @click="answer_collectionFun(myAnswerObj.id, myAnswerObj.subject.collection.is_collection)">
                      <Icon type="ios-star" v-if="myAnswerObj.subject.collection.is_collection.toString() == 'true'"/>
                      <Icon type="ios-star-outline"
                            v-if="myAnswerObj.subject.collection.is_collection.toString() == 'false'"/>
                      收藏
                    </div>
                  </div>
                </div>
                <div class="comments-list comments-list-div" v-if="myAnswerObj.show_comments_list == true">
                  <comments-list
                      reply_type="answer"
                      :reply_type_id="myAnswerObj.id"
                  ></comments-list>
                </div>
              </div>
              <div class="answer-list-div">
                <div class="line-div"></div>
              </div>
              <!--别人的回答-->
              <div class="answer-list-div" v-if="dataDetail.id">
                <answer-list
                    answer_type="answer"
                    :answer_type_id="dataDetail.id"
                ></answer-list>
              </div>
            </FormItem>

          </Form>
        </div>
        <div class="footer" :style="{width: DrawerWidth - 32 + 'px'}">

        </div>
      </Drawer>
      <!--收藏-->
      <Modal v-model="show_collection_modal" :width="600"
             class-name="vertical-center-modal" class="Modal-Detail-div">
        <h3 slot="header" style="color:#2D8CF0">收藏</h3>
        <div class="collection-div">
          <CheckboxGroup v-model="Checkbox_collection_group" class="Checkbox">
            <Checkbox v-for="(el,index) in collection_group_data" :key="index" :label="el.id">
              <span v-text="el.name"></span>
            </Checkbox>
          </CheckboxGroup>
        </div>
        <div slot="footer">
          <Button type="text" @click="hidecollectionModal">取消</Button>
          <Button type="primary" :loading="saveLoading" @click="savecollection()">确定</Button>
        </div>
      </Modal>
      <!--编辑-->
      <Drawer :closable="false" :width="WindowWidth" v-model="addCurrentTableData" class="Drawer-body">
        <div class="Drawer_pStyle">
          <span>编辑</span>
          <span class="del" @click="hideAddModal"><Icon type="md-close"/></span>
        </div>
        <div class="body">
          <table class="add-table" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="left paddingTop22" valign="top" align="right">
                <Form label-position="top" class="from-content">
                  <FormItem label="">
                    <Input v-model="addData.title" placeholder="请输入标题"></Input>
                  </FormItem>
                  <FormItem label="">
                    <!--<textarea name="content" id="content"></textarea>-->
                    <div id="content" class="ck-editor-content" :style="{minHeight: WindowHeight - 252 + 'px'}"></div>
                    <!--<div id="toolbar-container"></div>
                    <div id="editor" class="editor-content"></div>-->
                  </FormItem>
                </Form>
              </td>
              <td class="right" valign="top" :style="{width: WindowWidth > 1440 ? WindowWidth*0.3 + 'px' : '288px'}">
                <Form label-position="top">
                  <FormItem label="类别">
                    <Select v-model="addData.type" :transfer="true" style="width:100%;">
                      <Option v-for="item in typeArr" :value="item.id" :key="item.id">{{ item.title }}</Option>
                    </Select>
                  </FormItem>
                  <FormItem label="标签">
                    <Input v-model="addData.tags" placeholder="标签"></Input>
                  </FormItem>
                  <FormItem label="附件">
                    <div class="dataDetail-div chooseUser accessory">
                      <div class="users" v-for="el in addData.accessory">
                        <span class="span-name" v-text="el.name"></span>
                        <span class="span-icon" @click="delAccessory(el)">
                          <Icon type="close-round"></Icon>
                        </span>
                      </div>
                      <Upload
                          :before-upload="handleUpload" action="">
                        <Button icon="ios-cloud-upload-outline">选择文件</Button>
                      </Upload>
                    </div>
                  </FormItem>
                  <FormItem label="可见范围">
                    <div class="dataDetail-div">
                      <Tree ref="user_tree" :data="TreeData" show-checkbox multiple
                            @on-select-change="onSelectChange"></Tree>
                    </div>
                  </FormItem>
                </Form>
              </td>
            </tr>
          </table>
        </div>
        <div class="footer" :style="{width: WindowWidth - 32 + 'px'}">
          <Button type="text" @click="hideAddModal">取消</Button>
          <Button type="primary" :loading="saveLoading" @click="save()">确定</Button>
        </div>
      </Drawer>
      <!--人员详情-->
      <user-info
          :user_id="userInfo_id"
          @userInfoBackFun="userInfoBackFun"
      ></user-info>
    </Row>
  </div>
</template>

<script>
  import Cookies from 'js-cookie';
  import Util from '../../libs/util';
  import Utils from '../../libs/mod.utils';
  import String from '../../libs/mod.string';
  import Modal from '../../libs/mod.Modal';
  import Ckeditor from '../../libs/mod.ckeditor';
  import commentsList from '../components/comments-list.vue';
  import answerList from '../components/answer-list.vue';
  import userAvatar from '../components/user-avatar.vue';
  import userInfo from '../components/user-info.vue';
  export default {
    components: {
      commentsList,
      answerList,
      userAvatar,
      userInfo
    },
    data () {
      return {
        total: 0,
        page: 1,
        size: 10,
        readList_total: 0,
        readList_page: 1,
        sort: '',
        order: '',
        uid: '',
        id: '',
        officeappsUrl: Util.constant.officeappsUrl,
        show_users: '',
        searchConName: '',
        searchConTel: '',
        showCurrentTableData: false,
        loading: true,
        showCurrentColumns: [],
        editInlineAndCellData: [],
        columns: [
          {
            type: 'selection',
            width: 60,
            align: 'center'
          },
          {
            key: 'uname',
            title: '创建人',
            width: 100,
            align: 'center',
            sortable: 'custom',
          },
          {
            key: 'title',
            title: '标题',
            align: 'center',
            sortable: 'custom',
          },
          {
            key: 'type',
            title: '类别',
            align: 'center',
            sortable: 'custom',
            render: (h, params) => {
              return h('div', [
                h('span', params.row.type.title)
              ]);
            }
          },
          {
            key: 'tags',
            title: '标签',
            align: 'center',
            sortable: 'custom',
          },
          {
            key: 'start_time',
            title: '时间',
            align: 'center',
            sortable: 'custom',
            width: 170
          },
          {
            title: 'Action',
            key: 'action',
            width: 150,
            align: 'center',
            render: (h, params) => {
              var disabled = true;
              var data = params.row;
              var uid = data.uid || '';
              if (uid == this.uid) {// 只能修改自己的
                disabled = false;
              }
              return h('div', [
                h('Button', {
                  props: {
                    type: 'primary',
                    size: 'small',
                    disabled: disabled,
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: e => {
                      e.stopPropagation();
                      var data = params.row;
                      this.update(data, params.index);
                    }
                  }
                }, '修改')
              ]);
            }
          }
        ],
        data: [],
        dataDetail: {},
        initTable: [],
        addCurrentTableData: false,
        saveLoading: false,
        ajaxType: 'add',
        addData: {
          title: '',
          type: '',
          tags: '',
          users: [],
          departments: [],
          accessory: [],
          is_ckeditor: true,
          content: '',
        },
        selectionArr: [],
        editor: null,
        TreeData: [],
        checked_dep_arr: [],
        checked_users_arr: [],
        comePageTime: 0,// 进入页面的时间戳
        readList: [],
        readList_columns: [
          {
            key: 'name',
            title: '姓名',
          },
          {
            key: 'status',
            title: '阅读状态',
            render: (h, params) => {
              return h('div', [
                h('span', params.row.status == true ? '已读' : '未读')
              ]);
            }
          },
          {
            key: 'read_time',
            title: '阅读时间',
          },
        ],
        DrawerWidth: Util.constant.DrawerWidth,// 抽屉的宽度
        WindowWidth: Util.constant.WindowWidth,// 窗口的宽度
        WindowHeight: Util.constant.WindowHeight,// 窗口的高度
        typeSelectid: 'all',
        typeSelect: [
          {
            id: 'all',
            title: '全部',
          },
        ],
        typeArr: [],
        support: false,
        against: false,
        supportNum: 0,
        againstNum: 0,
        list_type: '',//收藏type
        list_tid: '',//收藏内容id
        list_is_collection: '',//是否收藏了
        show_collection_modal: false,
        myAnswer: false,// 是否写了 我的回答
        myAnswerObj: {},
        collection_group_data: [],
        Radio_collection_group: '',
        Checkbox_collection_group: [],
        show_answer_content: false,
        show_myanswer_content: false,
        answer_content: '',// 回答的内容
        answer_editor: null,
        answer_ajaxType: 'add',
        searchDatePicker: [],//搜索时间段
        from: '',
        to: '',
        userInfo_id: '',// 查看用户详情的用户id
      };
    },
    created: function () {
      var _this = this;
      _this.uid = Util.toJson(localStorage.getItem('userInfo')).id;

      // 收藏夹跳转过来的
      var collection_list_str = sessionStorage.getItem('collection_list');
      if (collection_list_str && collection_list_str != '') {
        var collection_list_obj = Util.toJson(collection_list_str);
        var id = collection_list_obj.id || '';
        var type = collection_list_obj.type || '';
        if (type == 'knowledge') {
          _this.readUpdate(collection_list_obj);
        }

        sessionStorage.removeItem('collection_list');
      }
    },
    beforeMount: function () {
      var _this = this;
      var comePageTime = _this.comePageTime;
      var timestamp = new Date().getTime();
      _this.comePageTime = timestamp;
    },
    beforeDestroy: function () {
      var _this = this;
      var comePageTime = _this.comePageTime;
      var timestamp = new Date().getTime();
      var type = Util.constant.statistical_type.knowledge.id;
      var seconds = Math.ceil((parseInt(timestamp) - parseInt(comePageTime)) / 1000);
      Util.statistical(_this, type, seconds);//保存数据
    },
    mounted () {
      this.getData();
      this.getTypeArr();
    },
    methods: {
      // 查看用户详情
      searchUserInfo: function (id) {
        var _this = this;
        _this.userInfo_id = id;
      },
      userInfoBackFun: function (id) {
        var _this = this;
        _this.userInfo_id = id;
      },
      // 支持
      supportFun: function (tid, is_support) {
        var _this = this;
        is_support = is_support.toString();
        if (is_support == 'true' && is_support != '') {//已经支持 -> 取消支持
          _this.supportSave(tid, 'knowledge', '', true, function (res) {
            if (res.result == 0) {
              if (_this.showCurrentTableData == true) {
                _this.dataDetail.subject.praise.support = _this.dataDetail.subject.praise.support - 1 >= 0 ? _this.dataDetail.subject.praise.support - 1 : 0;
                _this.dataDetail.subject.praise.is_support = '';
              }
            } else {
              _this.$Message.error('保存信息失败!');
            }
          });
        } else if (is_support == 'false' && is_support != '') {//已经反对 -> 变为支持
          _this.supportSave(tid, 'knowledge', true, false, function (res) {
            if (res.result == 0) {
              if (_this.showCurrentTableData == true) {
                _this.dataDetail.subject.praise.support = _this.dataDetail.subject.praise.support + 1;
                _this.dataDetail.subject.praise.against = _this.dataDetail.subject.praise.against - 1 >= 0 ? _this.dataDetail.subject.praise.against - 1 : 0;
                _this.dataDetail.subject.praise.is_support = true;
              }
            } else {
              _this.$Message.error('保存信息失败!');
            }
          });
        } else if (is_support == '' && is_support != 'false' && is_support != 'true') {//未支持未反对 -> 支持
          _this.supportSave(tid, 'knowledge', true, false, function (res) {
            if (res.result == 0) {
              if (_this.showCurrentTableData == true) {
                _this.dataDetail.subject.praise.support = _this.dataDetail.subject.praise.support + 1;
                _this.dataDetail.subject.praise.is_support = true;
              }
            } else {
              _this.$Message.error('保存信息失败!');
            }
          });
        }
      },
      // 反对
      againstFun: function (tid, is_support) {
        var _this = this;
        is_support = is_support.toString();
        if (is_support == 'true' && is_support != '') {//已经支持 -> 变为反对
          _this.supportSave(tid, 'knowledge', false, false, function (res) {
            if (res.result == 0) {
              if (_this.showCurrentTableData == true) {
                _this.dataDetail.subject.praise.support = _this.dataDetail.subject.praise.support - 1 >= 0 ? _this.dataDetail.subject.praise.support - 1 : 0;
                _this.dataDetail.subject.praise.against = _this.dataDetail.subject.praise.against + 1;
                _this.dataDetail.subject.praise.is_support = false;
              }
            } else {
              _this.$Message.error('保存信息失败!');
            }
          });
        } else if (is_support == 'false' && is_support != '') {//已经反对 -> 取消反对
          _this.supportSave(tid, 'knowledge', '', true, function (res) {
            if (res.result == 0) {
              if (_this.showCurrentTableData == true) {
                _this.dataDetail.subject.praise.against = _this.dataDetail.subject.praise.against - 1 >= 0 ? _this.dataDetail.subject.praise.against - 1 : 0;
                _this.dataDetail.subject.praise.is_support = '';
              }
            } else {
              _this.$Message.error('保存信息失败!');
            }
          });
        } else if (is_support == '' && is_support != 'false' && is_support != 'true') {//未支持未反对 -> 反对
          _this.supportSave(tid, 'knowledge', false, false, function (res) {
            if (res.result == 0) {
              if (_this.showCurrentTableData == true) {
                _this.dataDetail.subject.praise.against = _this.dataDetail.subject.praise.against + 1;
                _this.dataDetail.subject.praise.is_support = false;
              }
            } else {
              _this.$Message.error('保存信息失败!');
            }
          });
        }
      },
      // 支持反对保存
      supportSave: function (tid, type, is_support, is_cancel, _successFun) {
        var _this = this;
        var data = {
          uid: Util.toJson(localStorage.getItem('userInfo')).id,
          tid: tid,
          type: type,
          is_support: is_support,//"true 支持 false 反对"
          is_cancel: is_cancel,//"true 取消支持或取消反对"
        };
        var params = {
          url: '/support/save',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
      },
      // 收藏
      collectionFun: function (tid, is_collection) {
        var _this = this;
        _this.list_tid = tid;
        _this.list_is_collection = is_collection;
        _this.list_type = 'knowledge';
        is_collection = is_collection.toString();
        if (is_collection == 'true') {//已经收藏 -> 取消收藏
          _this.get_collection_group();
        } else if (is_collection == 'false') {//未收藏 -> 加入收藏
          _this.get_collection_group();
        }
      },
      //收藏夹列表
      get_collection_group: function () {
        var _this = this;
        var data = {
          uid: Util.toJson(localStorage.getItem('userInfo')).id,
          tid: _this.list_tid,
          type: _this.list_type,
        };
        var params = {
          url: '/collection/group/listForTid',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var _data = res.data || [];
            var Checkbox_collection_group = [];
            for (var k in _data) {
              if (!_data[k]) {
                continue;
              }
              if (_data[k].is_collection == 1) {
                Checkbox_collection_group.push(_data[k].id);
              }
            }
            _this.Checkbox_collection_group = Checkbox_collection_group;
            _this.collection_group_data = _data;
            _this.show_collection_modal = true;
          } else {
            _this.$Message.error('查询收藏夹信息失败!');
          }
        }
      },
      // 隐藏收藏夹
      hidecollectionModal: function () {
        var _this = this;
        _this.show_collection_modal = false;
      },
      // 保存收藏
      savecollection: function () {
        var _this = this;
        var Checkbox_collection_group = _this.Checkbox_collection_group;
        var data = {
          uid: Util.toJson(localStorage.getItem('userInfo')).id,
          tid: _this.list_tid,
          type: _this.list_type,
          gids: Checkbox_collection_group,
        };
        var params = {
          url: '/collection/update',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var is_collection = false;
            if (Checkbox_collection_group.length > 0) {
              is_collection = true;
            }
            if (_this.list_type == 'answer') {
              _this.myAnswerObj.subject.collection.is_collection = is_collection;
            } else {
              if (_this.showCurrentTableData == true) {
                _this.dataDetail.subject.collection.is_collection = is_collection;
              }
            }
            _this.show_collection_modal = false;
          } else {
            _this.$Message.error('收藏失败!');
          }
        }
      },
      // 取消收藏
      del_collection: function () {
        var _this = this;
        var data = {
          uid: Util.toJson(localStorage.getItem('userInfo')).id,
          tid: _this.list_tid,
          type: 'knowledge',
        };
        var params = {
          url: '/collection/delete',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var key = 'key_' + _this.list_tid;
            _this.data[key].subject.collection.is_collection = false;
          } else {
            _this.$Message.error('取消收藏失败!');
          }
        }
      },
      // 评论
      commentsFun: function (id) {
        var _this = this;
        var key = 'key_' + id;
        if (_this.showCurrentTableData == true) {
          if (_this.dataDetail.show_comments_list) {
            _this.dataDetail.show_comments_list = false;
          } else {
            _this.dataDetail.show_comments_list = true;
          }
        } else {
          if (_this.data[key].show_comments_list) {
            _this.data[key].show_comments_list = false;
          } else {
            _this.data[key].show_comments_list = true;
          }
        }
        _this.show_answer_content = false;
        _this.show_myanswer_content = false;
      },
      // 列表分类查询
      onChangeTypeSelect: function (val) {
        var _this = this;
        _this.typeSelectid = val;
        _this.page = 1;
        _this.getData();
      },
      DownloadFile: function (url, name) {
        var _this = this;
        if (url && name) {
          Utils.DownloadFile(url, name);
        }
      },
      onSelectChange: function (data) {
        var _this = this;
      },
      // 搜索
      searchFun: function () {
        var _this = this;
        var searchDatePicker = _this.searchDatePicker;
        var from = searchDatePicker[0] || '';
        var to = searchDatePicker[1] || '';
        if (from != '') {
          from = Utils.dateToDate(from);
        }
        if (to != '') {
          to = Utils.dateToDate(to);
        }
        _this.from = from;
        _this.to = to;

        _this.page = 1;
        _this.getData();
      },
      // 排序
      onSortChange: function (data) {
        var _this = this;
        var column = data.column;
        var key = data.key;
        switch (key) {
          case 'uname' :
            key = 'u.name';
            break;
          case 'title' :
            key = 'k.title';
            break;
          case 'type' :
            key = 'k.type';
            break;
          case 'tags' :
            key = 'k.tags';
            break;
          case 'start_time' :
            key = 'k.start_time';
            break;
        }
        var order = data.order;
        if (order == 'asc' || order == 'desc') {
          _this.sort = key;
          _this.order = order;
          _this.getData();
        } else {
          _this.sort = '';
          _this.order = '';
          _this.getData();
        }
      },
      getData () {
        var _this = this;
        var data = {
          uid: Util.toJson(localStorage.getItem('userInfo')).id,
          page: _this.page,
          size: _this.size,
          type: _this.typeSelectid == 'all' ? '' : _this.typeSelectid,
          sort: _this.sort,
          order: _this.order,
          from: _this.from,
          to: _this.to,
        };
        var params = {
          url: '/intell-lib/list',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var _data = res.data || [];
            _this.total = res.rows;
            var data = [];
            for (var k in _data) {
              if (!_data[k]) {
                continue;
              }
              var uid = _data[k].uid;
              var obj = _data[k];
              if (uid != _this.uid) {
                obj._disabled = true;
              }
              data.push(obj);
            }
            _this.data = data;
          } else {
            _this.$Message.error('查询信息失败!');
          }
        }
      },
      handleSearch () {
        var _this = this;
        _this.page = 1;
        var searchConName = _this.searchConName;
      },
      // 分页条
      changePage (page) {
        var _this = this;
        _this.page = page;
        _this.getData();
      },
      onRowData: function (data, index) {
        var _this = this;
        _this.readUpdate(data);
        _this.getMyAnswer(data);
      },
      show: function (Detail_data) {
        var _this = this;
        var id = Detail_data.id;
        _this.id = id;

        var data = {
          id: _this.id,
        };
        var params = {
          url: '/intell-lib/query',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var _data = res.data || [];
            var show_users_arr = [];
            var departments = _data.departments;
            for (var k in departments) {
              if (!departments[k]) {
                continue;
              }
              var name = departments[k].name;
              show_users_arr.push(name);
            }
            var users = _data.users;
            for (var k in users) {
              if (!users[k]) {
                continue;
              }
              var name = users[k].name;
              show_users_arr.push(name);
            }
            _this.show_users = show_users_arr.join(' ， ');
            _data.show_comments_list = false;
            _this.show_answer_content = false;
            _this.show_myanswer_content = false;
            _this.dataDetail = _data;
            _this.showCurrentTableData = true;
          } else {
            _this.$Message.error('查询信息失败!');
          }
        }
      },
      // 查看我的回答
      getMyAnswer: function (Detail_data) {
        var _this = this;
        var knowledge_id = Detail_data.id;
        var data = {
          knowledge_id: knowledge_id,
          id: '',
        };
        var params = {
          url: '/intell-lib/answer/query',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            if (res.data && res.data.id) {
              var data = res.data;
              _this.myAnswer = true;
              data.show_comments_list = false;
              _this.myAnswerObj = data;
            } else {
              _this.myAnswer = false;
            }
          } else {
            _this.$Message.error('查询我的回答失败!');
          }
        }
      },
      // 写回答 or 查看我的回答
      answerFun: function (knowledge_id) {
        var _this = this;
        _this.dataDetail.show_comments_list = false;
        if (_this.myAnswer == true) { // 已经写了
          _this.show_answer_content = false;
          _this.show_myanswer_content = !_this.show_myanswer_content;
        } else { // 还没写
          _this.answer_ajaxType = 'add';
          _this.show_answer_content = true;
          _this.show_myanswer_content = false;
          _this.initAnswerCkeditor();
        }
      },
      // 写回答，富文本
      initAnswerCkeditor () {
        var _this = this;
        _this.$nextTick(function () {
          if (_this.answer_editor) {
            _this.answer_editor.setData(_this.answer_content);
          } else {
            Ckeditor.initCkeditor(_this, 'answer_content', function (editor) {
              _this.answer_editor = editor;
              _this.answer_editor.setData(_this.answer_content);
            });
          }
        });
      },
      // 添加回答
      addAnswerFun: function () {
        var _this = this;
        var knowledge_id = _this.dataDetail.id;
        var myAnswer_id = _this.myAnswerObj.id ? _this.myAnswerObj.id : '';
        _this.saveAnswerFun(knowledge_id, myAnswer_id);
      },
      // 修改回答
      updateAnswerFun: function () {
        var _this = this;
        _this.answer_ajaxType = 'update';
        _this.answer_content = _this.myAnswerObj.content;
        _this.show_answer_content = true;
        _this.show_myanswer_content = false;
        _this.initAnswerCkeditor();
      },
      // 保存回答
      saveAnswerFun: function (knowledge_id, id) {
        var _this = this;
        var answer_content = _this.answer_editor ? _this.answer_editor.getData() : '';
        if (answer_content == '' || answer_content == '<p>&nbsp;</p>') {
          _this.$Message.error('请填写回答内容!');
          return false;
        }
        var data = {
          id: id,
          knowledge_id: knowledge_id,
          content: answer_content,
          anonymous: false,
        };
        var url = '/intell-lib/answer/add';
        if (_this.answer_ajaxType == 'update') {
          url = '/intell-lib/answer/update';
        }
        var params = {
          url: url,
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            _this.getMyAnswer(_this.dataDetail);
            _this.clearAnswerFun();
          } else {
            _this.$Message.error('保存信息失败!');
          }
        }
      },
      // 取消回答
      clearAnswerFun: function () {
        var _this = this;
        _this.show_answer_content = false;
        _this.show_myanswer_content = false;
        _this.answer_content = '';
        _this.answer_editor = null;
      },
      // 回答 支持
      answer_supportFun: function (tid, is_support) {
        var _this = this;
        is_support = is_support.toString();
        if (is_support == 'true' && is_support != '') {//已经支持 -> 取消支持
          _this.supportSave(tid, 'answer', '', true, function (res) {
            if (res.result == 0) {
              _this.myAnswerObj.subject.praise.support = _this.myAnswerObj.subject.praise.support - 1 >= 0 ? _this.myAnswerObj.subject.praise.support - 1 : 0;
              _this.myAnswerObj.subject.praise.is_support = '';
            } else {
              _this.$Message.error('保存信息失败!');
            }
          });
        } else if (is_support == 'false' && is_support != '') {//已经反对 -> 变为支持
          _this.supportSave(tid, 'answer', true, false, function (res) {
            if (res.result == 0) {
              _this.myAnswerObj.subject.praise.support = _this.myAnswerObj.subject.praise.support + 1;
              _this.myAnswerObj.subject.praise.against = _this.myAnswerObj.subject.praise.against - 1 >= 0 ? _this.myAnswerObj.subject.praise.against - 1 : 0;
              _this.myAnswerObj.subject.praise.is_support = true;
            } else {
              _this.$Message.error('保存信息失败!');
            }
          });
        } else if (is_support == '' && is_support != 'false' && is_support != 'true') {//未支持未反对 -> 支持
          _this.supportSave(tid, 'answer', true, false, function (res) {
            if (res.result == 0) {
              _this.myAnswerObj.subject.praise.support = _this.myAnswerObj.subject.praise.support + 1;
              _this.myAnswerObj.subject.praise.is_support = true;
            } else {
              _this.$Message.error('保存信息失败!');
            }
          });
        }
      },
      // 回答 反对
      answer_againstFun: function (tid, is_support) {
        var _this = this;
        is_support = is_support.toString();
        if (is_support == 'true' && is_support != '') {//已经支持 -> 变为反对
          _this.supportSave(tid, 'answer', false, false, function (res) {
            if (res.result == 0) {
              _this.myAnswerObj.subject.praise.support = _this.myAnswerObj.subject.praise.support - 1 >= 0 ? _this.myAnswerObj.subject.praise.support - 1 : 0;
              _this.myAnswerObj.subject.praise.against = _this.myAnswerObj.subject.praise.against + 1;
              _this.myAnswerObj.subject.praise.is_support = false;
            } else {
              _this.$Message.error('保存信息失败!');
            }
          });
        } else if (is_support == 'false' && is_support != '') {//已经反对 -> 取消反对
          _this.supportSave(tid, 'answer', '', true, function (res) {
            if (res.result == 0) {
              _this.myAnswerObj.subject.praise.against = _this.myAnswerObj.subject.praise.against - 1 >= 0 ? _this.myAnswerObj.subject.praise.against - 1 : 0;
              _this.myAnswerObj.subject.praise.is_support = '';
            } else {
              _this.$Message.error('保存信息失败!');
            }
          });
        } else if (is_support == '' && is_support != 'false' && is_support != 'true') {//未支持未反对 -> 反对
          _this.supportSave(tid, 'answer', false, false, function (res) {
            if (res.result == 0) {
              _this.myAnswerObj.subject.praise.against = _this.myAnswerObj.subject.praise.against + 1;
              _this.myAnswerObj.subject.praise.is_support = false;
            } else {
              _this.$Message.error('保存信息失败!');
            }
          });
        }
      },
      // 回答 评论
      answer_commentsFun: function (id) {
        var _this = this;
        if (_this.myAnswerObj.show_comments_list) {
          _this.myAnswerObj.show_comments_list = false;
        } else {
          _this.myAnswerObj.show_comments_list = true;
        }
      },
      // 回答 收藏
      answer_collectionFun: function (tid, is_collection) {
        var _this = this;
        _this.list_tid = tid;
        _this.list_is_collection = is_collection;
        _this.list_type = 'answer';
        _this.get_collection_group();
      },

      // 已读未读,分页条
      readList_changePage: function (page) {
        var _this = this;
        _this.readList_page = page;
        _this.getReadList();
      },
      // 更新已读
      readUpdate: function (Detail_data) {
        var _this = this;
        var id = Detail_data.id;
        _this.id = id;
        var data = {
          tid: _this.id,
          uid: Util.toJson(localStorage.getItem('userInfo')).id,
          type: 'knowledge',
        };
        var params = {
          url: '/read/status/update',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {

          } else {

          }
          _this.show(Detail_data);
          _this.readList_page = 1;
          _this.getReadList();
        }
      },
      // 查看已读列表
      getReadList: function () {
        var _this = this;
        var data = {
          tid: _this.id,
          uid: Util.toJson(localStorage.getItem('userInfo')).id,
          type: 'knowledge',
          page: _this.readList_page,
          size: _this.size,
        };
        var params = {
          url: '/read/status/list',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            _this.readList_total = res.rows || 0;
            _this.readList = res.data ? res.data : [];
          } else {
            _this.$Message.error('查询已读人员列表失败!');
          }
        }
      },
      asyncOK: function () {
        var _this = this;
        _this.showCurrentTableData = false;
      },
      // 获取选人 树信息
      getTreeData: function () {
        var _this = this;
        var data = {
          uid: Util.toJson(localStorage.getItem('userInfo')).id,
          id: 1
        };
        var params = {
          url: '/department/query',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var TreeData = [];
            TreeData.push(data);
            _this.toDataFun(TreeData);
            _this.TreeData = TreeData;
          } else {
            _this.$Message.error('查询人员信息失败!');
          }
        }
      },
      // 处理树信息
      toDataFun: function (arr) {
        var _this = this;
        arr.forEach(function (e) {
          e.title = e.name;
          e.expand = true;//展开
          if (e.type) {
            e.type = 'dep';
            var checked_dep_arr = _this.checked_dep_arr;
            if (Utils.idInArray(e.id, checked_dep_arr)) {
              e.checked = true;// 选中
            }
          } else {
            e.type = 'user';
            var checked_users_arr = _this.checked_users_arr;
            if (Utils.idInArray(e.id, checked_users_arr)) {
              e.checked = true;// 选中
            }
          }
          var staff = e.staff || [];
          var children = e.children || [];
          if (children.length == 0) {
            e.children = [];
          }
          e.children.push(...staff);
          _this.toDataFun(e.children);
        });
      },
      // 获取类别
      getTypeArr: function () {
        var _this = this;
        var data = {};
        var params = {
          url: '/intell-lib/type/list',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var _data = res.data || [];
            _this.typeArr = _data;
            _this.typeSelect.push(..._data);
          } else {
            _this.$Message.error('查询类别信息失败!');
          }
        }
      },
      // 富文本
      initCkeditor () {
        var _this = this;
        Ckeditor.initCkeditor(_this, 'content', function (editor) {
          _this.editor = editor;
          _this.editor.setData(_this.addData.content);
        });
      },
      // 选中文件
      handleUpload: function (file) {
        var _this = this;
        _this.UploadFile(file);
        return false;
      },
      // 上传文件
      UploadFile: function (file) {
        var _this = this;
        var formData = new FormData();
        formData.append("file", file);
        formData.append("action", "UploadVMKImagePath");
        var params = {
          url: '/file/addFile',
          type: Util.method.post,
          data: formData,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data;
            var id = data.id;
            var name = data.name;
            var url = data.url;
            var obj = {
              id: id,
              name: name,
              url: url,
            };
            _this.addData.accessory.push(obj);
          } else {
            _this.$Message.error('上传失败!');
          }
        }
      },
      // 删除附件
      delAccessory: function (el) {
        var _this = this;
        var id = el.id;
        var accessory = _this.addData.accessory;
        for (var k in accessory) {
          if (!accessory[k]) {
            continue;
          }
          if (id == accessory[k].id) {
            var del = accessory.splice(k, 1);
            break;
          }
        }
        _this.addData.accessory = accessory;
      },
      // 列表多选 选中数据
      selectionChange: function (selection) {
        var _this = this;
        _this.selectionArr = selection;
      },
      // 隐藏编辑页面
      hideAddModal: function () {
        var _this = this;
        var title = _this.addData.title;
        var content = _this.editor ? _this.editor.getData() : '';
        if (title == '' && (content == '' || content == '<p>&nbsp;</p>')) {
          _this.addCurrentTableData = false;
        } else {
          Modal.confirm(_this, {content: '取消编辑内容将丢失，请确认？'}, function () {
            _this.addCurrentTableData = false;
            if (_this.editor) {
              _this.editor.setData('');
            }
          }, function () {
          });
        }
      },
      // 显示添加界面
      add: function () {
        var _this = this;
        _this.ajaxType = 'add';
        _this.TreeData = [];
        _this.checked_dep_arr = [];
        _this.checked_users_arr = [];
        _this.addData.title = '';
        _this.addData.type = '';
        _this.addData.tags = '';
        _this.addData.users = [];
        _this.addData.departments = [];
        _this.addData.accessory = [];
        _this.addData.content = '';
        _this.getTreeData();
        _this.addCurrentTableData = true;
        if (!_this.editor) {
          _this.initCkeditor();
        } else {
          _this.editor.setData('');
        }

      },
      // 保存数据
      save: function () {
        var _this = this;
        var title = _this.addData.title;
        var type_id = _this.addData.type;
        var tags = _this.addData.tags;
        var accessory = _this.addData.accessory;
//        var content = _this.addData.content;
        var content = _this.editor ? _this.editor.getData() : '';
        var CheckedNodes = _this.$refs.user_tree.getCheckedNodes();
        if (!(title && title != '')) {
          _this.$Message.error('请填写标题!');
          return false;
        }
        if (!(type_id && type_id != '')) {
          _this.$Message.error('请选择类别!');
          return false;
        }
        if (CheckedNodes.length == 0) {
          _this.$Message.error('请选择可见范围!');
          return false;
        }
        if (!(content && content != '')) {
          _this.$Message.error('请填写内容!');
          return false;
        }
        var departments = [];
        var users = [];
        for (var k in CheckedNodes) {
          if (!CheckedNodes[k]) {
            continue;
          }
          var id = CheckedNodes[k].id;
          var type = CheckedNodes[k].type;
          if (type == 'dep') {
            departments.push(id);
          } else if (type == 'user') {
            users.push(id);
          }
        }
        var accessoryId = [];
        for (var k in accessory) {
          if (!accessory[k]) {
            continue;
          }
          var id = accessory[k].id;
          accessoryId.push(id);
        }
        departments = Utils.onlyArray(departments);
        users = Utils.onlyArray(users);
        accessoryId = Utils.onlyArray(accessoryId);
        var data = {
          id: _this.id,
          title: title,
          type: type_id,
          users: users,
          departments: departments,
          tags: tags,
          is_ckeditor: _this.addData.is_ckeditor,
          content: content,
          accessory: accessoryId,
        };
        var url = '/intell-lib/add';
        if (_this.ajaxType == 'update') {
          url = '/intell-lib/update';
        }
        var params = {
          url: url,
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        _this.saveLoading = true;
        function _successFun(res) {
          _this.saveLoading = false;
          if (res.result == 0) {
            _this.page = 1;
            _this.getData();
            _this.addCurrentTableData = false;
            _this.TreeData = [];
            _this.checked_users_arr = [];
            _this.addData.title = '';
            _this.addData.type = '';
            _this.addData.tags = '';
            _this.addData.users = [];
            _this.addData.departments = [];
            _this.addData.accessory = [];
            _this.addData.content = '';
            if (_this.editor) {
              _this.editor.setData('');
            }
          } else {
            _this.$Message.error('保存信息失败!');
          }
        }

      },
      // 显示修改界面
      update: function (data, index) {
        var _this = this;
        _this.ajaxType = 'update';
        var id = data.id;
        _this.id = id;
        var data = {
          id: _this.id,
        };
        var params = {
          url: '/intell-lib/query',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var _data = res.data || [];
            var checked_dep_arr = [];
            var checked_users_arr = [];
            var departments = _data.departments;
            for (var k in departments) {
              if (!departments[k]) {
                continue;
              }
              checked_dep_arr.push(departments[k]);
            }
            var users = _data.users;
            for (var k in users) {
              if (!users[k]) {
                continue;
              }
              checked_users_arr.push(users[k]);
            }
            var accessory = _data.accessory;
            var accessoryArr = [];
            for (var k in accessory) {
              if (!accessory[k]) {
                continue;
              }
              var obj = {
                id: accessory[k].id,
                name: accessory[k].name,
                url: accessory[k].path,
              };
              accessoryArr.push(obj);
            }
            _this.checked_users_arr = checked_users_arr;
            _this.checked_dep_arr = checked_dep_arr;
            _this.addData.title = _data.title;
            _this.addData.type = _data.type.id;
            _this.addData.tags = _data.tags;
            _this.addData.accessory = accessoryArr;
            _this.addData.content = _data.content;
            _this.getTreeData();
            _this.addCurrentTableData = true;
            if (!_this.editor) {
              _this.initCkeditor();
            } else {
              _this.editor.setData(_this.addData.content);
            }
          } else {
            _this.$Message.error('查询信息失败!');
          }
        }
      },
      // 删除
      remove: function () {
        var _this = this;
        var selectionArr = _this.selectionArr;
        if (selectionArr.length == 0) {
          _this.$Message.error('请填选择要删除的数据!');
          return false;
        }
        var selectionIds = [];
        for (var k in selectionArr) {
          if (!selectionArr[k]) {
            continue;
          }
          var id = selectionArr[k].id;
          selectionIds.push(id);
        }
        Modal.confirm(_this, {content: '确定删除选中的信息？'}, function () {
          var data = {
            id: selectionIds,
          };
          var params = {
            url: '/intell-lib/deleteMultiple',
            type: Util.method.get,
            data: data,
            success: _successFun
          };
          Util.ajax(_this, params);
          function _successFun(res) {
            if (res.result == 0) {
              _this.page = 1;
              _this.getData();
            } else {
              _this.$Message.error('删除信息失败!');
            }
          }
        }, function () {
        });
      },
      // 导出
      ExportData: function () {
        var _this = this;
        var fields = [
          {
            field: 'id',
            title: '#',
            type: 'int',
            order: 1,
          },
          {
            field: 'name',
            title: '创建人',
            type: 'varchar',
            order: 2,
          },
          {
            field: 'title',
            title: '标题',
            type: 'varchar',
            order: 3,
          },
          {
            field: 'tags',
            title: '标签',
            type: 'varchar',
            order: 4,
          },
          {
            field: 'start_time',
            title: '时间',
            type: 'datetime',
            order: 5,
          },
          {
            field: 'content',
            title: '内容',
            type: 'varchar',
            order: 6,
          },
        ];
        var fieldsStr = Util.toStr(fields);
        var data = {
          uid: Util.toJson(localStorage.getItem('userInfo')).id,
          type: 'knowledge',
          fields: fieldsStr,
        };
        var params = {
          url: '/file/db2excle',
          type: Util.method.post,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var url = res.data;
            var date = Utils.dateToDateString(new Date());
            Utils.DownloadFile(url, '导出知识库_' + date + '.xlsx');
          } else {
            _this.$Message.error('导出信息失败!');
          }
        }
      },
    }
  };
</script>
